﻿using System;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class Admin_Login : System.Web.UI.Page
{
    private void Page_Load(object sender, EventArgs e)
    {
        this.UserName.Focus();//获取焦点
    }

    protected void imgbtn_OK_Click(object sender, ImageClickEventArgs e)
    {
        if (base.IsValid)
        {
            if (Session["code"] != null)
            {

                if (Session["code"].ToString() == this.txtcode.Text)
                {
                    if (ManagerLogin.Login(this.UserName.Text.ToString(), this.Password.Text.ToString()))
                    {
                        string url = this.Session["loginUrl"].ToString();
                        base.Response.Redirect(url, true);
                    }
                    else
                    {
                        this.ShowErr.Text = "用户或密码错误！";
                    }
                }
                else
                {
                    this.ShowErr.Text = "验证码错误！";
                    this.txtcode.Text = "";
                }
            }
            else
            {
                this.ShowErr.Text = "验证码过期！";
                this.txtcode.Text = "";
            }
        }
    }

    protected void imgbtn_Canle_Click(object sender, ImageClickEventArgs e)
    {
        this.UserName.Text = "";
        this.Password.Text = "";
        this.txtcode.Text = "";
    }
}
